package com.ruiben.mall.controller;

import com.ruiben.mall.impl.OrderBackServiceImpl;
import com.ruiben.mall.pojo.UserOrderBack;
import com.ruiben.mall.utils.CommonJSONResult;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("orderback")
public class OrderBackController extends BaseController {

    @Autowired
    private OrderBackServiceImpl orderBackService;

    @PostMapping("getReturnGoodsList")
    public CommonJSONResult getReturnGoodsList(String userId,Integer orderStatus){

        if (StringUtils.isBlank(userId)) {
            return CommonJSONResult.errorMsg("用户id不能为空");
        }

        List<UserOrderBack> returnGoodsList = orderBackService.getReturnGoodsList(userId);
        return CommonJSONResult.ok(returnGoodsList);

    }

    @PostMapping("delReturnGoodsOrder")
    public CommonJSONResult delReturnGoodsOrder(String backId, String backGoodsId){
        if (StringUtils.isBlank(backId)){
            return CommonJSONResult.errorMsg("id不能为空");
        }

        orderBackService.delReturnGoodsOrder(backId, backGoodsId);
        return CommonJSONResult.ok();
    }
}
